package com.Controller;
import com.Service.ManagerService;
import com.pojo.Author;
import com.pojo.Book;
import com.pojo.BookProfile;
import com.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/show")
public class ManagerController {
    @Autowired
    private ManagerService managerService;

    @GetMapping("/getAllUser")
    @ResponseBody
    public Map<String,Object> getUser(int page, int rows) throws SQLException {
        return managerService.getUser(page,rows);
    }
    @PostMapping("/updateUserInfo")
    @ResponseBody
    public void updateUserInfo(@RequestBody User user) throws SQLException {
         managerService.updateUserInfo(user);
    }
    @PostMapping("deleteUserInfo")
    @ResponseBody
    public void deleteUserInfo(@RequestParam String id) throws SQLException {
        managerService.deleteUserInfo(id);
    }
    @GetMapping("/getAllAuthor")
    @ResponseBody
    public Map<String,Object> getAuthor(int page, int rows) throws SQLException {
      return managerService.getAuthor(page,rows);
    }
    @PostMapping("updateAuthor")
    @ResponseBody
    public void updateAuthorInfo(@RequestBody Author author) throws SQLException {
        managerService.updateAuthorInfo(author);
    }
    @PostMapping("/updateStatus")
    @ResponseBody
    public void updateStatus(@RequestParam String id,@RequestParam String status) throws SQLException {
      managerService.updateStatus(id,status);
    }
    @PostMapping("/deleteAuthorInfo")
    @ResponseBody
    public void deleteInfo(@RequestParam String id) throws SQLException {
        managerService.deleteAuthorInfo(id);
    }
    @GetMapping("/getAllBook")
    @ResponseBody
    public Map<String,Object> getAllBook(int page,int rows) throws SQLException {
     return managerService.getALlBook(page,rows);
    }
    @PostMapping("/deleteBookInfo")
    @ResponseBody
    public void deleteBookInfo(@RequestParam String id) throws SQLException {
        managerService.deleteBookInfo(id);
    }
    @GetMapping("getBookProfile")
    @ResponseBody
    public List<BookProfile> getBookProfile(@RequestParam String id) throws SQLException {
       return managerService.getBookProfile(id);
    }
}
